package com.itwang.common;

import java.util.Date;

//日志类
public class Logger {

	/***
	 * 日志等级
	 * 0,都不显示
	 * 1,只显示error和key info
	 * 2,显示err,key info,info.
	 * 3,显示error,key info,info,debug.
	 *
	 *
	 */
	private static Integer logClass = 4;
	
	static {
		//获取配置文件中的日志等级
		logClass = Integer.valueOf(PropertiesUtil.getKey("logClass"));
	}
	//错误信息
	public static void error(String msg) {
		if (logClass >= 1) {
			System.err.println("[ERROR]: " + msg);
			System.err.println("[ERROR]: " + new Date());
			System.err.println("===========================================================");
		}
	}
	
	//关键日志信息
	public static void keyInfo(String msg) {
		if (logClass >= 1) {
			System.err.println("[KEY-INFO]: " + msg);
			System.err.println("[KEY-INFO]: " + new Date());
			System.err.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
		}
	}
	
	//日志信息
	public static void info(String msg) {
		if (logClass >= 2) {
			System.out.println("[INFO]: " + msg);
			System.out.println("[INFO]: " + new Date());
			System.out.println("===========================================================");
		}
		
	}
	//调试信息
	public static void debug(String msg) {
		if (logClass >= 3) {
			System.out.println("[DEBUG]: " + msg);
			System.out.println("[DEBUG]: " + new Date());
			System.out.println("===========================================================");
		}
	}
	
	
}
